<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="apple-touch-fullscreen" content="yes">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="format-detection" content="telephone=no">

        <title>轩盛商品分类筛选</title>
        <link href="__CSS__/screeningcss/base.css" rel="stylesheet">
        <link href="__CSS__/screeningcss/home.css" rel="stylesheet">
        <link href="__CSS__/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
        <link href="__CSS__/index.css" rel="stylesheet">


        <link href="__CSS__/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
        <link href="__CSS__/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
        <link href="__CSS__/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
        <link href="__CSS__/animate.min.css" rel="stylesheet">
        <link href="__CSS__/style.min862f.css?v=4.1.0" rel="stylesheet">
        <link href="__JS__/layui/css/layui.css"rel="stylesheet">
        
        <style>
         .table {table-layout:fixed;}
        </style>

    </head>
    <body>
        
        <div class="text-center">
            <p style="font-size: 30px">{$scheme}</p>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row headBack" style=" margin:0">
            <div class="input-group" style=" margin:10px auto; width: 90%;">
                <input type="text" id="searchContent" style="width: 100%;float: right;" class="form-control" placeholder="请在这里输入商品名称"/>

                 <span class="input-group-addon" onclick="Refreshtable()"><i class="glyphicon glyphicon-search"></i></span>
            </div>
        </div>
        

        <section class="aui-screen-box">
            <div class="aui-screen-content">
                <div class="aui-choice-screen">
                    <div class="aui-screen-head-choice">
                        <dl>
                            <dt>已选条件：</dt>
                            <dd style="display:none" class=aui-clear-delete>
                                <div class=aui-clear-list></div>
                                <div style="display:none" class="aui-eliminate">清除筛选条件</div>
                            </dd>
                        </dl>
                    </div>
                    <div id="aui-selectList" class="aui-screen-list-box">
                        <dl class="aui-screen-list-item" attr="terminal_brand_s">
                            <dt>一级：</dt>
                            <dd  id="list1">
                                <!-- <a href="javascript:void(0)" values2="" values1="" attrval="微型车">微型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="小型车">小型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="紧凑型车">紧凑型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="中型车">中型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="中大型车">中大型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="大型车">大型车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="全部SUV">全部SUV</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="MPV">MPV</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="跑车">跑车</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="皮卡">皮卡</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="微面">微面</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="轻客">轻客</a> -->
                            </dd>
                        </dl>
                        <dl class="aui-screen-list-item" attr="">
                            <dt>二级：</dt>
                            <dd id="list2">
                                <a href="javascript:void(0)" values2="" values1="" attrval="暂无数据">暂无数据</a>
                  <!--               <a href="javascript:void(0)" values2="" values1="" attrval="5-8万">5-8万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="8-12万">8-12万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="12-18万">12-18万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="18-25万">18-25万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="25-40万">25-40万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="40-80万">40-80万</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="80万以上">80万以上</a>
                                <label class="aui-sr-input">
                                    <input type="text" placeholder="" value="">
                                    -
		                            <input type="text" placeholder="" value="">
                                    <button>确认</button>
                                </label> -->
                            </dd>
                        </dl>
                        <dl class=" aui-screen-list-item" attr="aui-terminal">
                            <dt>三级：</dt>
                            <dd id="list3">
                                 <a href="javascript:void(0)" values2="" values1="" attrval="暂无数据">暂无数据</a>
                         <!--        <a href="javascript:void(0)" values2="" values1="" attrval="">20-55岁</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="">30-55岁</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="">20-55岁</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="">20-55岁</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="">20-55岁</a>
                                <a href="javascript:void(0)" values2="" values1="" attrval="">20-55岁</a> -->
                            </dd>
                        </dl>
                       
                    </div>
                </div>
            </div>
        </section>
    
       <table id="tableEvents" data-mobile-responsive="true">
            <!-- <thead>
                <tr>
                    <th data-field="state" data-checkbox="true"></th>
                    <th data-field="id">分类id</th>
                    <th data-field="name">分类名称</th>
                    <th data-field="control">操作</th>
                </tr>
            </thead> -->
        </table>

        <div style="height: 50px;"></div>

        <div class="form-group">

            <div class="col-sm-2 col-sm-offset-5">
                <button lay-submit lay-filter="upload" class="btn btn-primary btn-block" name="Qualifications" id="inquiry" value="confirm" type="submit">挑选完成</button>
            </div>

        </div>

        <div style="height: 100px;"></div>
 
        <!-- <script src="__JS__/screeningjs/jquery-1.4.3.min.js"></script>  -->

        <script src="__JS__/jquery.min.js?v=2.1.4"></script>
        <script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
        <script src="__JS__/content.min.js?v=1.0.0"></script>
        <script src="__JS__/plugins/bootstrap-table/bootstrap-table.min.js"></script>
        <script src="__JS__/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
        <script src="__JS__/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
        <script src="__JS__/layui/layui.js"></script> 

        <script type="text/javascript">

             // 全局变量
        var g_ClassfiyId;
        var hlight = [];
        var scheme = "{$scheme}"
        var order_sn = "{$order_sn}"
        // 判断是否全选
        var judgeSelect = ""
        var ASelect = 0


           // 引用layui
        layui.use(['layer', 'form'], function(){
          var layer = layui.layer;
          var form = layui.form;
        });

    // 常用变量
        // bootstrap-table
        $table = $('#tableEvents');
        // 表单
        $formTable = $('#formTable');

	        var dlNum = $("#aui-selectList").find("dl");
	        for (i = 0; i < dlNum.length; i++) {
	            $(".aui-screen-head-choice .aui-clear-list").append("<div class=\"aui-selected-info selectedShow\" style=\"display:none\"><span></span><label></label><em></em></div>");
	        }
	        var refresh = "true";
                    // live改on 选择类的a标签
	        $(".aui-screen-list-item ").on("click","a", function() {
	            var text = $(this).text();
	            var selectedShow = $(".selectedShow");
	            var textTypeIndex = $(this).parents("dl").index();
	            var textType = $(this).parent("dd").siblings("dt").text();
	            index = textTypeIndex - (2);
	            $(".aui-clear-delete").show();
	            $(".selectedShow").eq(index).show();
	            $(this).addClass("selected").siblings().removeClass("selected");
	            selectedShow.eq(index).find("span").text(textType);
	            selectedShow.eq(index).find("label").text(text);
	            var show = $(".selectedShow").length - $(".selectedShow:hidden").length;
	            if (show > 1) {
	                $(".aui-eliminate").show();
	            }

	        });
	        $(".selectedShow").on("click","em", function() {
	            $(this).parents(".selectedShow").hide();
	            var textTypeIndex = $(this).parents(".selectedShow").index();
	            index = textTypeIndex;
	            $(".aui-screen-list-item").eq(index).find("a").removeClass("selected");

	            if ($(".aui-screen-list-item .selected").length < 2) {
	                $(".aui-eliminate").hide();
	            }
	        });

	        $(".aui-eliminate").on("click", function() {
	            $(".selectedShow").hide();
	            $(this).hide();
	            $(".aui-screen-list-item a ").removeClass("selected");

	        });



    // 初始化 bootstrap-table
        $table.bootstrapTable({
            url: "ajaxGoodsinfo",
            method: 'post',
            responseHandler:function(res){
                return res;
            },
            search: true,
            searchOnEnterKey:true,
            // 分页
            pagination: false,
            showRefresh: true,
            showColumns:true,
            uniqueId:'cat_id',
            // showToggle: true,
            // showColumns: true,
            iconSize: "outline",
            toolbar: "#tableEventsToolbar",
            icons: {
                refresh: "glyphicon-repeat",
                Columns: "glyphicon-list-alt",
                // columns: "glyphicon-list"
            },
            columns:[


                {field: "state",checkbox:true},
                // {field:'id',title:'操作',align:'center',formatter:function(value,row,index){
                //     judgeSelect = index+1;
                //     // console.log(judgeSelect);
                //     var value = value;
                //     var rowIndex = index;
                //     var result = '';
                //      result += ` <input type="text" style="width: 100%;" name=Reasons/>` ;
                //     // result += ` <button class="btn btn-info classifyRemove" data-rowIndex="${rowIndex}" data-ClassfiyId="${value}" onclick="Highlight(this)" title="订单高亮"><i class="fa fa-eye"></i></button>` ;
                //     // result += ` <a class="btn btn-primary updata" data-rowIndex="${rowIndex}" data-ClassfiyId="${value}" onClick="updateData(this)" title="修改商品"><i class="fa fa-pencil"></i></a> `;
                //     // result += ` <button class="btn btn-danger classifyRemove" data-rowIndex="${rowIndex}" data-ClassfiyId="${value}" onClick="deleteData(this)" title="删除商品"><i class="fa fa-trash-o"></i></button>`;
                //     return result;
                // },width:'100'},
                // {field:'pic',title:'商品图片',align: 'center',width:'200',formatter:function(value,row,index){
                //     var value = value;
                //     var result = `<img src="${value}" style="width:100px; height:100px;"></img>`;
                //     return result;
                // }},
                // {field:'price',title:'产品额度',sortable:true,align: 'center',width:'200'},
                {field:'name',title:'商品名称',align: 'center',width:'100'},
                {field:'aga',title:'① 年龄要求',align: 'center',width:'100'},
                {field:'type',title:'商品分类',align: 'center',width:'100'},
                // {field:'introduce',title:'商品简介',align: 'center',width:'200'},
                {field:'job_information',title:'② 工作信息',align: 'center',width:'150'},
                {field:'loan_multiples_requirements',title:'③ 保单缴费次数 / 供房记录/供车记录/社保/公积金/工薪/个税/其他',align: 'center',width:'1000'},
                {field:'settle',title:'④ 结清',align: 'center',width:'100'},
                {field:'overpayment',title:'⑤ 复效、超缴费日期',align: 'center',width:'150'},
                {field:'area',title:'⑥ 区号',align: 'center',width:'80'},
                {field:'know',title:'⑦ 配偶是否知情',align: 'center',width:'120'},
                {field:'inspect',title:'⑧ 是否上门考察',align: 'center',width:'100'},
                {field:'hang',title:'⑨ 挂靠单位',align: 'center',width:'100'},
                {field:'else',title:'⑩ 其他',align: 'center',width:'80'},
                {field:'credit_investigation',title:'⑪ 征信查询次数',align: 'center',width:'300'},
                {field:'credit',title:'⑫ 征信显示',align: 'center',width:'200'},
                // {field:'content',title:'产品详情',align: 'center',width:'1200'},

            ],
            striped:true,

                // 全选
              onCheckAll: function (index) {  
               
               judgeSelect = index.length;
               ASelect = index.length;
               console.log(judgeSelect);
               // console.log(typeof judgeSelect);

                },  
                // 取消全选   
              onUncheckAll: function (rows) {  
               
               judgeSelect = "";
               //             console.log(judgeSelect);
               // console.log(typeof judgeSelect);
                },  
                    // 单选
                onCheck:function(row){
                  ASelect++;  
                  console.log(ASelect);    
                },
                // 取消单选
                 onUncheck:function(row){
                  --ASelect;  
                  console.log(ASelect);      
                },

        })    


            // 加载分类初始数据
           $(function(){

            $.ajax({

                type:"get",

                url:"ajaxCatinfo",

                success:function(data){

                    var html = "";

                    var html2 = "";

                    // console.log(data);
                   
                    // 后台传过来的是 对象字符串

                        // 将字符串 转成 Json对象

                    // var jsonObj = $.parseJSON(data);

                    // 遍历Json对象

                    $.each(data,function(i,v){


                    // console.log(i);
                    // console.log(v);

                    html+=`

                        <a href="javascript:void(0)" values2="" values1="" attrval="${v.id}"  data-goods="${v.id}" onclick="changeNav(this)" >${v.name}</a>

                    `

                        // if (i=="商品") {

                        //     for(var j=0; j<v.length;j++){

                        //     html2+=`   

                        //         <a href="javascript:void(0)" values2="" values1="" attrval="${v[j].cat_name}" data-type="${v[j].cat_name}" onclick="search(this)">${v[j].cat_name}</a>


                        //         `
                        //      }
                        // }


                    })



                    $('#list1').append(html);
                   
                    


                },

                async:true

            });


           })


           // 点击更换分类

        function changeNav(e){

                var goods = e.dataset.goods;

                 console.log(goods);
            $.ajax({

                type:"post",

                url:"ajaxCatinfo",

                data:'id='+goods,

                success:function(data){

                    console.log(data);

                    var html = '';

                    // 遍历Json对象

                    $.each(data,function(i,v){


                    html+=`

                        <a href="javascript:void(0)" values2="" values1="" attrval="${v.id}"  data-goods="${v.id}" onclick="changeNav1(this)" >${v.name}</a>

                    `

                    })  

                        
                    $('#list2').html(html);

                },

                async:true

            });     

            Refreshtable(goods);

        }

        // 三级分类
     function changeNav1(e){

                    var goods = e.dataset.goods;

                     console.log(goods);
                $.ajax({

                    type:"post",

                    url:"ajaxCatinfo",

                    data:'id='+goods,

                    success:function(data){

                        console.log(data);

                        var html = '';

                        // 遍历Json对象

                        $.each(data,function(i,v){


                        html+=`

                            <a href="javascript:void(0)" values2="" values1="" attrval="${v.id}" onclick="Refreshtable(${v.id})" data-goods="${v.id}" >${v.name}</a>

                        `

                        })  

                            
                        $('#list3').html(html);

                    },

                    async:true

                });  

                Refreshtable(goods);   

            }

                // 三级搜索商品
             function Refreshtable(goods){

                // 清空选中值
                ASelect=0;

                console.log(goods);

                console.log(typeof goods);

                var txt = $('#searchContent').val();

                if (txt != "") {
                     $("#tableEvents").bootstrapTable('refresh',{'url':"ajaxGoodsinfo?goodsName="+txt}); 

                }else{
                    $("#tableEvents").bootstrapTable('refresh',{'url':"ajaxGoodsinfo?id="+goods}); 
                }
                // 重新刷新列表
            

              goods = "";

              txt = "";

              var txt = $('#searchContent').val("");
        
            }






            $("#inquiry").on('click',function(){

                    var a= $table.bootstrapTable('getSelections');

                    console.log(ASelect);
                    console.log(judgeSelect);

                // if (a.length > 0 && ASelect!=judgeSelect ) {

                //     layer.prompt({title: '请问为什么不选其他产品', formType: 2}, function(text, index){
                //     layer.close(index);
                //     layer.msg('因为：'+text);
                    
                //      });
                    
                //  }else if (a.length > 0 && ASelect==judgeSelect){
                //     var text ="未填写";
                //     Finalchoice(text);
                //  }
                if (a.length > 0 && ASelect!=judgeSelect ) {

                    Finalchoice();

                }else if (a.length == 0){
                    layer.msg('请勾选产品');
                 }
                
                
            })


            // 高亮
             function Highlight(e){
            hlight += e.dataset.classfiyid;
            $(e).parent().addClass("Highlight");
            hlight += "/";
            console.log(hlight);
            console.log(scheme);
            console.log(order_sn);
        }

        // 获取版本号
        function getUrlParms(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)
            return unescape(r[2]);
            return null;
        }

        var versions = getUrlParms('versions');
       
        console.log(versions);
        // console.log(typeof result);


                    // 跳转
             function Finalchoice(){
                    // 获取选中的值赋值给A
                var a= $table.bootstrapTable('getSelections');


                // JSON.parse(jsonstr); //可以将json字符串转换成json对象 
                // JSON.stringify(jsonobj); //可以将json对象转换成json对符串 
                var jsonData = JSON.stringify(a);

                console.log(typeof jsonData);

                // console.log(text);

                  console.log(jsonData);

                $.ajax({

                    type:"post",

                    url:"ajaxZizhi",

                   
                    data:{
                        'id':jsonData,
                        'hlightid':hlight,
                        'order_sn':order_sn,
                        'scheme':scheme,
                        'versions':versions,
                        // 'cause':text,
                    },

                    success:function(data){

                        // console.log('{:url('order/noSelect')}?order='+data+'&versions='+versions);
                        // 带订单号跳转Pass页面
                        window.location.href='{:url('order/noSelect')}?order='+data+'&versions='+versions;
                        


                    },

                    async:true

                });  
            }

        </script>
    </body>
</html>
